#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int numTrees(int n)
    {
        vector<int> dp(n + 1, -1);
        dp[0] = 1;
        dp[1] = 1;
        return numTreesDP(n, dp);
    }

    int numTreesDP(int n, vector<int> &dp)
    {
        if (dp[n] != -1)
            return dp[n];
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            count += numTreesDP(i, dp) * numTreesDP(n - i - 1, dp);
        }
        return dp[n] = count;
    }
};

int main()
{
    cout << "Code96" << endl;
    Solution s;
    cout << s.numTrees(3) << endl;
    return 0;
}